package com.myz.eureka.server;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

/**
 * eureka注册中心搭建，启动服务中心 @EnableEurekaServer
 * <p>
 * eureka是一个高可用的组件，它没有后端缓存，每一个实例注册之后需要向注册中心发送心跳（因此可以在内存中完成）
 * <p>
 * 集群启动 java -jar eureka-server-0.0.1-SNAPSHOT.jar - -spring.profiles.active=dev1
 *
 * @author maoyz0621
 */
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {

    private static final Logger logger = LoggerFactory.getLogger(EurekaServerApplication.class);

    public static void main(String[] args) {
        try {
            SpringApplication.run(EurekaServerApplication.class, args);
            StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
            for (StackTraceElement element : stackTrace) {
                String className = element.getClassName();
                String fileName = element.getFileName();
                int lineNumber = element.getLineNumber();
                String methodName = element.getMethodName();
                logger.info("******** className = [{}],fileName = [{}],lineNumber = [{}],methodName = [{}] *********", fileName, className, lineNumber, methodName);
            }
        } catch (Exception e) {
            logger.error("{}", e);
        }
    }
}
